Skip to content

fix(cli): base the exit code on the resolutions a problem is visible in - #285

Open
mib00038 wants to merge 1 commit into
arethetypeswrong:mainfrom
mib00038:fix/exit-code-visible-problems
Open

mib00038 wants to merge 1 commit into
arethetypeswrong:mainfrom
mib00038:fix/exit-code-visible-problems

Conversation

@mib00038

@mib00038 mib00038 commented Nov 6, 2026

Copy link
Copy Markdown

Fixes #284.

getExitCode honoured --profile only for problems carrying a resolutionKind field (4 of 12 kinds). The other eight always counted toward exit 1, so --profile esm-only exited 1 on a package whose only problems were visible under node10 or node16-cjs, while the table labelled them "(ignored)".

Change

getExitCode now counts a problem when it is not rule-ignored and problemAffectsResolutionKind is true for at least one resolution kind the profile does not ignore. That is the predicate render/typed.ts already uses for "(ignored per resolution)", so the exit code and the table agree. No change to core or to problem shapes, so this composes with #278.

Tests

packages/cli/test/getExitCode.test.ts, on in-memory packages: an InternalResolutionError visible only under node10 and a FalseCJS visible only under node16-cjs exit 0 under ["node10", "node16-cjs"] and 1 when the resolution they appear in is required (both exit-0 assertions fail on main with actual: 1, expected: 0); a problem visible in all four kinds still exits 1 while any of its kinds is required; --ignore-rules still applies to required resolutions. Core and CLI snapshots are unchanged.

Known limit

Core computes moduleKinds for node16 only (checkPackage.ts), so FalseCJS, FalseESM and UnexpectedModuleSyntax are never attributed to bundler. The table already shows nothing for them in the bundler cell; the exit code now follows the table there too.

Investigated and drafted with AI assistance; the reproduction is on #284 and the tests here are for you to check.

getExitCode counted a problem unless it carried resolutionKind and that kind was ignored. Eight problem kinds carry no resolutionKind, so a problem that affects only ignored resolutions still produced exit 1. Count a problem only when it affects a resolution that is not ignored.
@changeset-bot

changeset-bot Bot commented Nov 6, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 0546cac

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@arethetypeswrong/cli Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

--profile is ignored by the exit code for problem kinds without resolutionKind (InternalResolutionError, FalseCJS, …)

1 participant